package com.yzw.phonestoreservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yzw.phonestoreservice.pojo.User;
import com.yzw.phonestoreservice.service.UserService;
import com.yzw.phonestoreservice.mapper.UserMapper;
import com.yzw.phonestoreservice.vo.LoginVo;
import org.springframework.stereotype.Service;

/**
* @author YU
* @description 针对表【tb_user(用户)】的数据库操作Service实现
* @createDate 2022-11-04 10:46:04
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{

    @Override
    public User login(LoginVo loginVo) {

        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(User::getUsername,loginVo.getUsername()).eq(User::getPassword,loginVo.getPassword());
        User currentUser = this.getOne(queryWrapper);
        return currentUser;
    }

    @Override
    public User infoById(int userId) {

        User userById = this.getById(userId);
        return userById;
    }
}




